package com.udf.flink.udsf;

import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.InputGroup;
import org.apache.flink.table.functions.FunctionContext;
import org.apache.flink.table.functions.ScalarFunction;

public class HashFunction extends ScalarFunction {
    private int factor = 1;

    @Override
    public void open(FunctionContext context) throws Exception {
        factor = Integer.parseInt(context.getJobParameter("hashcode_factor", "1"));
    }

    public int eval(@DataTypeHint(inputGroup = InputGroup.ANY) Object o) {
        return o.hashCode();
    }
}
